package com.itheima.io1.myobjectstream;

/**
 * @author zhangbaiyan
 * @date 2024-09-21 19:26
 * @description: 序列化流创建对象
 * @version: 1.0
 */

import java.io.Serial;
import java.io.Serializable;

/**
 * serializable接口里面是没有抽象方法,标记型接口
 * 一旦实现这个接口,那么就表示当前的Stydent类可以被序列化
 * 理解:一个物品的合格证
 */
public class Student implements Serializable {

    private static final long serialVersionUID = -5369976439934455855L;

    private String name;
    private int age;
    //transient:瞬态关键字
    //作用:不会把当前属性序列化到本地文件当中
    private transient String address;
    private int id;


    public Student() {
    }

    public Student(String name, int age, String address, int id) {
        this.name = name;
        this.age = age;
        this.address = address;
        this.id = id;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     * @return id
     */
    public int getId() {
        return id;
    }

    /**
     * 设置
     * @param id
     */
    public void setId(int id) {
        this.id = id;
    }

    public String toString() {
        return "Student{name = " + name + ", age = " + age + ", address = " + address + ", id = " + id + "}";
    }
}
